package online.szlib.com.core.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

@Entity
@Table(name="comments")
public class Comment implements Serializable {

	private static final long serialVersionUID = -723512058586873439L;
	
	public Comment(){}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY) //strategy = GenerationType.AUTO
	@Column(name = "commentid", length = 10)
	private Long commentId;
	
	@Column(name = "uid", length = 10)
	private Integer userId;
	
	@Column(name = "uname", length = 256)
	private String userName;
	
	@Column(name="bookid", length = 10)
	private Integer bookId;
	
	@Column(name = "bookname", length = 256)
	private String bookName;
	
	@Column(name = "commenttime", nullable = false, length = 256)
	@Temporal(TemporalType.TIMESTAMP)
	private Date commentTime;
	
	@Column(name="comment")
	@Lob @Basic(fetch=FetchType.LAZY)
	private String memo;
	
	@Column(name = "refid", length = 10)
	private Integer refId;
	
	@Column(name = "grade", length = 10)
	private Integer grade;
	
	public Long getCommentId() {
		return commentId;
	}

	public void setCommentId(Long commentId) {
		this.commentId = commentId;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public Integer getBookId() {
		return bookId;
	}

	public void setBookId(Integer bookId) {
		this.bookId = bookId;
	}

	public String getBookName() {
		return bookName;
	}

	public void setBookName(String bookName) {
		this.bookName = bookName;
	}

	public Date getCommentTime() {
		return commentTime;
	}

	public void setCommentTime(Date commentTime) {
		this.commentTime = commentTime;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public Integer getRefId() {
		return refId;
	}

	public void setRefId(Integer refId) {
		this.refId = refId;
	}

	public Integer getGrade() {
		return grade;
	}

	public void setGrade(Integer grade) {
		this.grade = grade;
	}

	public String toString() {
        return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }
}
